package com.java.thread.effective;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;

/**
 * User: wujun
 * Date: 2014/12/9
 */
public class Main {
    private static Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
        ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(3, new RejectedExecutionHandler(){
            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                logger.debug("Waiting for new thread to run.");
            }
        });
        executorService.scheduleAtFixedRate(new ThreadWorker(), 1, 2, TimeUnit.SECONDS);
    }
}
